package service

import (
	"github.com/gogf/gf/v2/net/ghttp"
)

var Route route

type route struct {
	group *ghttp.RouterGroup
}

func (r *route) Group(group *ghttp.RouterGroup) *route {
	r.group = group

	return r
}

func (r *route) CURD(path string, handle interface{}) *route {
	r.group.Group(path, func(group *ghttp.RouterGroup) {
		group.GET("/", handle.(Curd).List)          // 列表
		group.GET("/:id", handle.(Curd).Show)       // 详情
		group.POST("/", handle.(Curd).Store)        // 创建
		group.PUT("/:id", handle.(Curd).Update)     // 更新
		group.DELETE("/:id", handle.(Curd).Destroy) // 删除
	})

	return r
}
